package com.example.springbootdemo.lifecycle;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class Dog implements ApplicationContextAware {

    public Dog() {
        System.out.println("执行 Dog 构造函数");
    }

    // 注解方式执行 初始化和销毁bean逻辑
    @PostConstruct
    public void init(){
        System.out.println("@PostConstruct 注解方式初始化bean。。。。。");
    }
    @PreDestroy
    public void destroy() {
        System.out.println("@PreDestroy 注解方式后置销毁bean。。。。。");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

    }
}
